﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 脚本辅助器
/// </summary>
[DisallowMultipleComponent]
public class ScriptHelper : MonoBehaviour
{
    /// <summary>
    /// 脚本名
    /// </summary>
    [SerializeField]
    private string m_ScrpitName;
    /// <summary>
    /// 脚本名
    /// </summary>
    public string ScriptName => m_ScrpitName;

#if UNITY_EDITOR

    private void OnValidate()
    {
        if (m_ScrpitName.IsNullOrEmpty())
        {
            m_ScrpitName = gameObject.name;
            Logger.Log("脚本名 {0} 为空，自动设置 {0} 为 {1}".Format(
                nameof(ScriptName).RichTextGreenColor(),
                gameObject.name.ToString().RichTextGreenColor()));
        }
    }

#endif
}
